package com.yunji.news.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yunji.news.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 分类Mapper接口
 *
 * @author yunji
 * @since 2024-11-23
 */
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    
    /**
     * 获取启用的分类列表
     */
    @Select("SELECT * FROM categories WHERE status = 1 AND deleted = 0 " +
            "ORDER BY sort_order ASC, id ASC")
    List<Category> selectEnabledCategories();
    
    /**
     * 根据编码获取分类
     */
    @Select("SELECT * FROM categories WHERE code = #{code} AND deleted = 0")
    Category selectByCode(String code);
}